<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>直播聊天室发送消息</title>
    <meta content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
          name="viewport">
    <meta content="ie=edge" http-equiv="X-UA-Compatible">
    <link href="/static/chat/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/chat/css/jquery-sinaEmotion-2.1.0.min.css" rel="stylesheet">
    <link href="/static/chat/css/style.css" rel="stylesheet">

    <script type="text/javascript" src="/static/chat/js/swfobject.js"></script>
    <script type="text/javascript" src="/static/chat/js/web_socket.js"></script>
    <script type="text/javascript" src="/static/chat/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/chat/js/jquery-sinaEmotion-2.1.0.min.js"></script>
    <script type="text/javascript" src="/static/chat/js/md5.js"></script>

    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
            font-size: 0;
        }

        .message-box {
            width: 100%;
            position: fixed;
            bottom: 36px;
            text-align: center;
            display: none;
            z-index: 1000;
        }

        .message {
            display: inline-block;
            font-size: 16px;
            padding: 7px 13px;
            border-radius: 9px;
            background-color: #6F6F6F;
            color: white;
        }

        img {
            width: 100%;
        }
    </style>
</head>
<body onload="connect()" style="padding:100px 50px;">
<div class="message-box">
    <div class="message"></div>
</div>

<select id="pop_type" style="width:100%;height:50px;color:#000;font-size:20px;" onchange="selectChange(this.value)" name="pop"
        value="">
    <option value="">请选择一个请求</option>
    <option value="login_h5">action login_h5</option>
    <option value="login_app_not_login">action login_app_not_login 用户端App（未登录） ws登录</option>
    <option value="login_app_logined">action login_app_logined 用户端App（已登录） ws登录</option>
    <option value="login_app_liver">action login_app_liver 主播端App（已登录） ws登录</option>
    <option value="login_astro">action astro_consult_login 咨询师端App ws登录</option>
    <option value="zyhs_consult_login">action zyhs_consult_login 【准有好事】用户端APP（连线咨询） ws登录</option>

    <option value="send_zan">action send_zan</option>
    <option value="online_info">online_info</option>
    <option value="pop_header">pop_header</option>
    <option value="pop_gift">pop_gift</option>
    <option value="pop_user_come">pop_user_come</option>
    <option value="pop_zan_sign">pop_zan_sign</option>
    <option value="pop_recommend">pop_recommend</option>
    <option value="pop_coupon">pop_coupon</option>
    <option value="pop_award_start">pop_award_start</option>
    <option value="pop_msg-1">pop_msg-1</option>
    <option value="pop_msg-2">pop_msg-2</option>
    <option value="pop_msg_liver_order">pop_msg_liver_order</option>
    <option value="change_camera_radio">change_camera_radio</option>
    <option value="action_user">action_user</option>
    <option value="pop_msg_liver_order">pop_msg_liver_order</option>
    <option value="close_recommend_goods">close_recommend_goods</option>
    <option value="live_status">live_status</option>
    <option value="send_zan_random">【压测】随机多次发送点赞数据（不需要登录）</option>
    <option value="send_user_com_random">【压测】随机多次发送**来了消息数据（不需要登录）</option>
    <option value="send_msg_random">【压测】随机多次发送聊天消息数据（不需要登录）</option>
    <option value="send_gift_random">【压测】随机多次发送礼物数据（不需要登录）</option>
    <option value="test_close_group">模拟关闭聊天室，客户端重连ws测试（不需要登录，比如：并发量高了以后，弹出的服务器，自动释放的时候）</option>
    <option value="login_app_logined_more">action login_app_logined 用户端App（已登录） ws登录，1000压测</option>
    <option value="send_zan_more">action send_zan，1000次压测</option>
    <option value="zyhs_send_user_com_random">【压测-准有好事】随机多次发送**来了消息数据（不需要登录）</option>
    <option value="zyhs_good_rtc_live_close">【压测-准有好事】关闭直播（不需要登录）</option>
    <option value="zyhs_good_rtc_live_online_msg">【压测-准有好事】更新在线人数（不需要登录）</option>
</select>

<textarea id="msg" style="width:100%;height:500px;margin-top:30px;color:#000;font-size:20px;" rows="3" cols="20" value="test"></textarea>

<div style="display: flex;">
    <div style="display: flex;align-items: center;margin-top: 30px;">
        <label style="color:#000;font-size:20px;">准了或者准有好事的直播间id：</label>
        <input id="live_id" style="width:80px;height:30px;color:#000;font-size:20px;" value=""/>
    </div>
    <div style="display: flex;align-items: center;margin-top: 30px;margin-left: 20px;">
        <label style="color:#000;font-size:20px;">用户id（类型为action_user的时候，有效）：</label>
        <input id="user_id" style="width:80px;height:30px;color:#000;font-size:20px;" value=""/>
    </div>
    <div style="display: flex;align-items: center;margin-top: 30px;margin-left: 20px;">
        <label style="color:#000;font-size:20px;">ws client_id（类型为action_user的时候，有效）：</label>
        <input id="client_id" style="width:80px;height:30px;color:#000;font-size:20px;" value=""/>
    </div>
</div>

<button style="width:100%;height:50px;margin-top:30px;font-size:20px;color:#000;" type="button" onclick="send()">发送</button>

<textarea id="msg_ws" style="width:100%;height:500px;margin-top:30px;color:#000;font-size:20px;" rows="3" cols="20"
          value="test"></textarea>

</body>
<script type="text/javascript" src="{$oss}active/seven/js/jquery-v2.1.1.min.js"></script>
<script type="text/javascript">

    var ws, name, client_list = {}, room_id, client_id;//websocket变量

    var pop = 'online_info';//类型
    var msg = '';//发送的消息
    var msg_ws = '';//ws的消息

    function selectChange(value) {
        pop = value;
        console.log(value);
        switch (value) {
            case 'login_h5': {
                var time = Date.parse(new Date()) / 1000; //1603009257000,精确到秒
                // md5(md5(time=1629095750&action=login&live_id=1&app-type=h5)+'BvHa9WjkN1GceKg5')
                console.log('login_h5 h5_key_of_ws_login=', h5_key_of_ws_login)
                var live_id = $('#live_id').val();
                var sign = hex_md5(hex_md5('time=' + time + '&action=login&live_id=' + live_id + '&app-type=h5') + h5_key_of_ws_login);
                msg = '{"live_id":' + live_id + ',"action":"login","params":{"time":' + time + ',"app-type":"h5","sign":"' + sign + '"}}';

                break;
            }
            case 'login_app_not_login': {
                var live_id = $('#live_id').val();
                msg = '{"live_id":' + live_id + ',"action":"login","params":{"did":"EC21E9B9-8763-4626-B785-FF64574837E2","app-type":"ios","model":"iPhone 7 Plus","time":"1629539649","phone-version":"ios:12.4.1","version":"2.7.0","distinct-id":"5CE5EDAA-2A6E-4D89-ABA7-376CC40B2C45","sign":"KkzHDPmQm+bVGlH9DqB6WpwuXOn7tssMHO\\/3muU6dJK3F2s8o7s7Hnwx3U1u28Gg9xknlrFEbY40cjx25SojxnYN+upvt6qtIV3Lp\\/l+uRJ81B8FXUNWIzBeR8Undf8ONkxqAIZainBUCt1YfMNmneXMExxTSRR53BnLq6hMmfhiSM36OmSWRRobW7t3yJMv"}}';
                break;
            }
            case 'login_app_logined_more':
            case 'login_app_logined': {
                var live_id = $('#live_id').val();
                msg = '{"live_id":' + live_id + ',"action":"login","params":{"did":"EC21E9B9-8763-4626-B785-FF64574837E2","app-type":"ios","access-token":"54qAvIp8niveZzNUJ8H2xcfwjTk4HknC1Z6xrr87i15Viy5l4JZFrmWIAkgWX/x8KNQpv7HLmrOHTi3/Xt1wYA==","model":"iPhone 7 Plus","time":"1629539649","phone-version":"ios:12.4.1","version":"2.7.0","distinct-id":"5CE5EDAA-2A6E-4D89-ABA7-376CC40B2C45","sign":"KkzHDPmQm+bVGlH9DqB6WpwuXOn7tssMHO\\/3muU6dJK3F2s8o7s7Hnwx3U1u28Gg9xknlrFEbY40cjx25SojxnYN+upvt6qtIV3Lp\\/l+uRJ81B8FXUNWIzBeR8Undf8ONkxqAIZainBUCt1YfMNmneXMExxTSRR53BnLq6hMmfhiSM36OmSWRRobW7t3yJMv"}}';
                break;
            }
            case 'login_app_liver': {
                var live_id = $('#live_id').val();
                msg = '{"live_id":' + live_id + ',"action":"login","is_liver":1,"params":{"did":"D00B0372-9898-4C5E-9D1A-726FFA54BD9F","app-type":"ios","access-token":"i3vmldrSGc0uRYbOWEf9BwMQvz2MMSlmQOfEHTtxZ1CUcR0KkkoBlYtrp0O91M+MY780ZeaV+q0i4jslzbLMtA==","model":"iPhone 6 Plus","time":"1632710403","phone-version":"ios:12.5.1","version":"1.0","distinct-id":"5CE5EDAA-2A6E-4D89-ABA7-376CC40B2C45","sign":"dYpWtnu9F99dLGpb9y1C61V4eTmVEI4/55z2YTh4WgjMO4348fNF9wZ4298k4heoXbJJ7le+Y6MNjfCUqp9JX10caSuxLfVNvgrq+H3y0bF9YpzXOvXo+zojW5F+sPg7GFuA4JuJYboJD6De1W2KT9tf0fTYyt8cfltxvRIfojA="}}';

                break;
            }
            case 'login_astro':
                msg = '{\n' +
                    '    "action": "astro_consult_login",\n' +
                    '    "params": {\n' +
                    '        "app-type": "ios",\n' +
                    '        "did": "notAgree_ios",\n' +
                    '        "sign": "KkzHDPmQm+bVGlH9DqB6WhSVo26xlr/IU+w3qpTLkVS02wu2ZF20AjLLiJl7oTE3s+niqP8mQeV7dVxAZh7ILjQNrywfi9v+kUZmSBuLsd8qwxHciaK0Zy2dHldQWKmvpgT/wrVwSyziuh2ZbvpmSQ==",\n' +
                    '        "time": "1693297637",\n' +
                    '        "access-token": "GQ+80Wq6/13JvO4YckPxXYnhZp1a4fPkSRcoElWmkMYgYh6TQBNzy7sWS5YU85i4",\n' +
                    '        "version": "1.0.0"\n' +
                    '    }\n' +
                    '}';
                break;
            case 'zyhs_consult_login':
                msg = '{\n' +
                    '    "action": "zyhs_consult_login",\n' +
                    '    "params": {\n' +
                    '        "app-type": "ios",\n' +
                    '        "did": "ffffffff-bd08-ad79-ffff-ffffca6e6645",\n' +
                    '        "sign": "zQhO8h5W3ZPVL5QpzYiJ1J0XWxtoMr2e41kmtMgaXmoaDx2WioDxVl1/JkdJVyrNwu/bAIT6pRwDaEzXluuQpf5e1bllTH6NVOgiOdcGZBiVCGo+2S/fNZvwISCKVjb4xWe4Xr97i8EETjdMVQLANBvIt2WlDhR/UB7iP0i4M/iQPVZpGTdiudwtFy4gRSn1",\n' +
                    '        "model": "iPhone 8",\n' +
                    '        "phone-version": "ios:13.3.1",\n' +
                    '        "time": "1696731192000",\n' +
                    '        "timezone": "8",\n' +
                    '        "access-token": "HZw6L9Zi0yX6AaJlJ5uT9yHPnUbHJSldEvNiOXIQwGHPwger2LP16NgOs3ZK1d5s",\n' +
                    '        "version": "1.0.0",\n' +
                    '        "live_record_id": "1",\n' +
                    '        "live_type": "1"\n' +
                    '    }\n' +
                    '}';
                break;
            case 'send_zan_more':
            case 'send_zan': {
                var live_id = $('#live_id').val();
                var sign = Math.ceil(Math.random() * 12);
                msg = '{"live_id":' + live_id + ',"action":"send_zan","params":{"sign":' + sign + '}}';
                break;
            }
            case 'online_info': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"成功",\n' +
                    '    "data":{\n' +
                    '        "type":"online_info",\n' +
                    '        "online_info":{\n' +
                    '            "online_num":25444,\n' +
                    '            "hot_num":"2.5万"\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_header': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"成功",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_header",\n' +
                    '        "pop_header":{\n' +
                    '            "continue_second":10,\n' +
                    '            "title":"恭喜***荣升榜一！",\n' +
                    '            "target":"",\n' +
                    '            "link":""\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_gift': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"发送礼物的消息",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_gift",\n' +
                    '        "pop_gift":{\n' +
                    '            "user_info":{\n' +
                    '                "uen":"776d22bdafd9",\n' +
                    '                "name":"我儿童",\n' +
                    '                "avatar":"/uploads/avatar/20200925/c6252be325da00742457beaf26c0ae42.png",\n' +
                    '                "vip_level":4,\n' +
                    '                "rank_index":-1\n' +
                    '            },\n' +
                    '            "gift_info":{\n' +
                    '                "id":1,\n' +
                    '                "name":"送出小行星",\n' +
                    '                "count":10,\n' +
                    '                "img":"/uploads/avatar/20200925/c6252be325da00742457beaf26c0ae42.png",\n' +
                    '                "coin":500,\n' +
                    '                "lottie":{\n' +
                    '                    "url":"/mini/divination_or_taro/taro_detail/lottie/data.json",\n' +
                    '                    "width_ratio_of_width":1,\n' +
                    '                    "height_ratio_of_width":1,\n' +
                    '                    "left_ratio_of_width":0,\n' +
                    '                    "bottom_ratio_of_width":0,\n' +
                    '                    "loop_num":2\n' +
                    '                }\n' +
                    '            }\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_user_come': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"我儿童进入直播间",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_user_come",\n' +
                    '        "pop_user_come":{\n' +
                    '            "user_info":{\n' +
                    '                "uen":"776d22bdafd9",\n' +
                    '                "name":"我儿童",\n' +
                    '                "avatar":"/uploads/avatar/20200925/c6252be325da00742457beaf26c0ae42.png",\n' +
                    '                "vip_level":4,\n' +
                    '                "rank_index":-1\n' +
                    '            },\n' +
                    '            "des":"我儿童进入直播间"\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_zan_sign': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"点赞",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_zan_sign",\n' +
                    '        "pop_zan_sign":3\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_recommend': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"主播推荐商品",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_recommend",\n' +
                    '        "pop_recommend":{\n' +
                    '            "title":"主播推荐",\n' +
                    '            "img":"/uploads/avatar/20200925/c6252be325da00742457beaf26c0ae42.png",\n' +
                    '            "name":"定制报告",\n' +
                    '            "original_price_des":"原价558元",\n' +
                    '            "now_price":"558",\n' +
                    '            "btn_info":{\n' +
                    '                "name":"现在购买",\n' +
                    '                "target":"local",\n' +
                    '                "link":"custom_report_index?need_auth=0"\n' +
                    '            }\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_coupon': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"主播推荐商品",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_coupon",\n' +
                    '        "pop_coupon":{\n' +
                    '            "id":1,\n' +
                    '            "title":"优惠券",\n' +
                    '            "img":"/uploads/avatar/20200925/c6252be325da00742457beaf26c0ae42.png",\n' +
                    '            "name":"学业报告八折券",\n' +
                    '            "is_only_vip_show":1\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_award_start': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"主播推荐商品",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_award_start",\n' +
                    '        "pop_award_start":{\n' +
                    '            "id":1,\n' +
                    '            "title":"主播抽奖",\n' +
                    '            "continue_second":300,\n' +
                    '            "list":[\n' +
                    '                {\n' +
                    '                    "title":"参与方式：",\n' +
                    '                    "des_info":{\n' +
                    '                        "name":"发送指定弹幕",\n' +
                    '                        "is_show_left_time":0,\n' +
                    '                        "target":"",\n' +
                    '                        "link":""\n' +
                    '                    }\n' +
                    '                },\n' +
                    '                {\n' +
                    '                    "title":"指定弹幕：",\n' +
                    '                    "des_info":{\n' +
                    '                        "name":"水逆退散！",\n' +
                    '                        "is_show_left_time":0,\n' +
                    '                        "target":"local",\n' +
                    '                        "link":"live_comment?text=%E6%B0%B4%E9%80%86%E9%80%80%E6%95%A3%EF%BC%81&need_auth=2"\n' +
                    '                    }\n' +
                    '                },\n' +
                    '                {\n' +
                    '                    "title":"",\n' +
                    '                    "des_info":{\n' +
                    '                        "is_show_left_time":0,\n' +
                    '                        "name":"",\n' +
                    '                        "target":"",\n' +
                    '                        "link":""\n' +
                    '                    }\n' +
                    '                },\n' +
                    '                {\n' +
                    '                    "title":"时间：",\n' +
                    '                    "des_info":{\n' +
                    '                        "is_show_left_time":1,\n' +
                    '                        "name":"5分钟",\n' +
                    '                        "target":"",\n' +
                    '                        "link":""\n' +
                    '                    }\n' +
                    '                },\n' +
                    '                {\n' +
                    '                    "title":"奖品：",\n' +
                    '                    "des_info":{\n' +
                    '                        "is_show_left_time":0,\n' +
                    '                        "name":"准有好运",\n' +
                    '                        "target":"local",\n' +
                    '                        "link":"live_gift_position?id=1&need_auth=0"\n' +
                    '                    }\n' +
                    '                },\n' +
                    '                {\n' +
                    '                    "title":"数量：",\n' +
                    '                    "des_info":{\n' +
                    '                        "is_show_left_time":0,\n' +
                    '                        "name":"3人",\n' +
                    '                        "target":"",\n' +
                    '                        "link":""\n' +
                    '                    }\n' +
                    '                }\n' +
                    '            ]\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_msg-1': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"发送的消息",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_msg",\n' +
                    '        "pop_msg":{\n' +
                    '            "user_info":{\n' +
                    '                "uen":"776d22bdafd9",\n' +
                    '                "name":"我儿童",\n' +
                    '                "avatar":"/uploads/avatar/20200925/c6252be325da00742457beaf26c0ae42.png",\n' +
                    '                "vip_level":4,\n' +
                    '                "rank_index":-1\n' +
                    '            },\n' +
                    '            "msg_info":{\n' +
                    '                "id":123,\n' +
                    '                "color":"#ffffff",\n' +
                    '                "content":"直播好精彩啊！直播好精彩啊！直播好精彩啊！直播好精彩啊！直播好精彩啊！直播好精彩啊！直播好精彩啊！直播好精彩啊！直播好精彩啊！直播好精彩啊！"\n' +
                    '            }\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_msg-2': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"发送的消息",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_msg",\n' +
                    '        "pop_msg":{\n' +
                    '            "msg_info":{\n' +
                    '                "id":123,\n' +
                    '                "color":"#ffffff",\n' +
                    '                "content":"主播提示：各位小行星，在线观看一定时长可以领取免费礼物哦～"\n' +
                    '            }\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_msg_liver_order': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"发送的消息",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_msg_liver_order",\n' +
                    '        "pop_msg_liver_order":{\n' +
                    '            "user_info":{\n' +
                    '                "uen":"776d22bdafd9",\n' +
                    '                "name":"我儿童",\n' +
                    '                "avatar":"/uploads/avatar/20200925/c6252be325da00742457beaf26c0ae42.png",\n' +
                    '                "vip_level":4,\n' +
                    '                "rank_index":-1\n' +
                    '            },\n' +
                    '            "msg_info":{\n' +
                    '                "id":123,\n' +
                    '                "color":"#ffffff",\n' +
                    '                "content":"mark购买了年度日运（169元）"\n' +
                    '            }\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'change_camera_radio': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"主播的摄像头、麦克风状态变化通知",\n' +
                    '    "data":{\n' +
                    '        "type":"change_camera_radio",\n' +
                    '        "change_camera_radio":{\n' +
                    '            "camera_status":1,\n' +
                    '            "radio_status":0\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'action_user': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"直播间用户管理",\n' +
                    '    "data":{\n' +
                    '        "type":"action_user",\n' +
                    '        "action_user":1\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'pop_msg_liver_order': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"主播端收到购买商品的消息",\n' +
                    '    "data":{\n' +
                    '        "type":"pop_msg_liver_order",\n' +
                    '        "pop_msg_liver_order":{\n' +
                    '            "user_info":{\n' +
                    '                "uen":"776d22bdafd9",\n' +
                    '                "name":"我儿童123",\n' +
                    '                "avatar":"/uploads/avatar/20200925/c6252be325da00742457beaf26c0ae42.png",\n' +
                    '                "vip_level":4,\n' +
                    '                "rank_index":-1\n' +
                    '            },\n' +
                    '            "msg_info":{\n' +
                    '                "color":"#fff",\n' +
                    '                "content":"***购买了***",\n' +
                    '                "id":"123"\n' +
                    '            }\n' +
                    '        }\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'close_recommend_goods': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"关闭推荐商品",\n' +
                    '    "data":{\n' +
                    '        "type":"close_recommend_goods",\n' +
                    '        "close_recommend_goods":1\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'live_status': {
                msg = '{\n' +
                    '    "code":200,\n' +
                    '    "msg":"直播结束",\n' +
                    '    "data":{\n' +
                    '        "type":"live_status",\n' +
                    '        "live_status":1\n' +
                    '    }\n' +
                    '}';
                break;
            }
            case 'send_zan_random':
            case 'send_user_com_random':
            case 'zyhs_send_user_com_random':
            case 'send_msg_random':
            case 'send_gift_random': {
                msg = '请在这里输入发送的次数，注意：这里只能输入数字类型！';
                break;
            }
            case 'test_close_group': {
                msg = '';
                break;
            }
            case 'zyhs_good_rtc_live_online_msg': {
                msg = '在这里输入要更新的在线人数！';
                break;
            }

        }

        console.log(msg);
        document.getElementById("msg").value = msg;
    }

    function send() {
        var live_id = $('#live_id').val();
        var user_id = $('#user_id').val();
        var client_id = $('#client_id').val();
        var msg = document.getElementById("msg").value;

        console.log('send live_id=', live_id, 'user_id=', user_id, 'client_id=', client_id, 'msg=', msg)
        if (pop === 'login_h5') {
            ws.send(msg);
        } else if (pop === 'login_app_not_login') {
            ws.send(msg);
        } else if (pop === 'login_app_logined') {
            ws.send(msg);
        } else if (pop === 'login_app_liver') {
            ws.send(msg);
        } else if (pop === 'login_astro') {
            ws.send(msg);
        } else if (pop === 'zyhs_consult_login') {
            ws.send(msg);
        } else if (pop === 'send_zan') {
            ws.send(msg);
        } else if (pop === 'login_app_logined_more') {
            for (var i = 0; i < 100; i++) {
                ws.send(msg);
            }
        } else if (pop === 'send_zan_more') {
            for (var i = 0; i < 100; i++) {
                ws.send(msg);
                console.log('send zan msg=', msg)
            }
        } else {
            if (pop.indexOf("-") !== -1) {
                pop = pop.split('-')[0];
            }
            $.ajax({
                url: '/test/test_websocket/send',
                type: 'POST',
                dataType: 'json',
                data: {
                    type: pop,
                    live_id,
                    user_id,
                    client_id,
                    content: JSON.stringify(msg)
                },
                success: function (res) {
                    if (res.code == 200) {
                    } else {
                    }
                    toast(res.msg);
                }
            })
        }
    }

    function toast(text) {
        $('.message').text(text);
        $('.message-box').show();
        setTimeout(function () {
            $('.message-box').hide();
            a = 1;
        }, 2500);
    }


    var websocket_gateway = '{$websocket_gateway}';
    var h5_key_of_ws_login = '{$h5_key_of_ws_login}';
    console.log('websocket_gateway=', websocket_gateway, 'h5_key_of_ws_login=', h5_key_of_ws_login)
    // 如果浏览器不支持websocket，会使用这个flash自动模拟websocket协议，此过程对开发者透明
    WEB_SOCKET_SWF_LOCATION = "/static/chat/swf/WebSocketMain.swf";
    // 开启flash的websocket debug
    WEB_SOCKET_DEBUG = true;


    room_id = getQueryString('room_id') ? getQueryString('room_id') : 1;

    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }

    var timer = null;

    // 连接服务端
    function connect() {
        // 创建websocket
        ws = new WebSocket(websocket_gateway);
        // 当socket连接打开时，输入用户名
        ws.onopen = onopen;
        // 当有消息时根据消息类型显示不同信息
        ws.onmessage = onmessage;
        ws.onclose = function (e) {
            // console.log("ws连接关闭，定时重连 e=", e);
            // connect();
            var msg = 'ws连接关闭！';
            toast(msg);
            console.error(msg);
            setMsg(msg);
            clearInterval(timer);//停止
            timer = null;
        };
        ws.onerror = function (e) {
            var msg = 'ws连接出错！';
            toast(msg);
            console.error("ws出现错误 e=", e);
            setMsg(msg);
            clearInterval(timer);//停止
            timer = null;
        };
    }

    // 连接建立时发送登录信息
    function onopen() {
        var msg = 'ws连接成功！';
        toast(msg);
        console.log('ws连接成功！');
        setMsg(msg);
        //每隔10s，发送心跳数据
        var i = 0;
        timer = setInterval(function () {
            console.log('心跳 ' + (++i));
            ws.send('{"action":"ping"}');
        }, 10000);
    }

    // 服务端发来消息时
    function onmessage(e) {
        console.log('接收到消息' + e.data);
        setMsg(e.data);
    }

    function setMsg(msg) {
        msg_ws += msg + "\n";
        document.getElementById("msg_ws").value = msg_ws;
    }


</script>

</html>
